package org.csu.mypetstore.api.persistence;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.csu.mypetstore.api.entity.Sequence;


public interface SequenceMapper extends BaseMapper<Sequence> {
    @Select("SELECT * FROM sequence WHERE name = #{name} FOR UPDATE")
    Sequence getSequenceForUpdate(String name);

    @Update("UPDATE sequence SET nextid = #{nextId} WHERE name = #{name}")
    int updateNextId(String name, int nextId);
}
